var uniquePaths = function(m, n) {
    let cache = {}

    function gen(row, col) {
        if (row === 0 && col === 0) {
            return 1
        }
        if (row < 0 || row > m - 1 || col < 0 || col > n - 1) {
            return 0
        }

        if (cache[row + '-' + col]) {
            return cache[row + '-' + col]
        } else {
            let temp = gen(row - 1, col) + gen(row, col - 1)
            cache[row + '-' + col] = temp
            return temp
        }
    }

    return gen(m - 1, n - 1)
};
console.log(uniquePaths(23, 10))